﻿using UnityEngine;

public static class ExtensionMethods
{
    public static string ToVectorString(this Vector3 vector)
    {
        return vector.x + "," + vector.y + "," + vector.z;
    }

    public static Vector3 ToVector(this string vectorString)
    {
        var coords = vectorString.Split(',');
        var x = float.Parse(coords[0]);
        var y = float.Parse(coords[1]);
        var z = float.Parse(coords[2]);
        return new Vector3(x, y, z);
    }

    public static string ToQuaternionString(this Quaternion quaternion)
    {
        return quaternion.x + "," + quaternion.y + "," + quaternion.z + "," + quaternion.w;
    }

    public static Quaternion ToQuaternion(this string quaternionString)
    {
        var coords = quaternionString.Split(',');
        var x = float.Parse(coords[0]);
        var y = float.Parse(coords[1]);
        var z = float.Parse(coords[2]);
        var w = float.Parse(coords[2]);
        return new Quaternion(x, y, z, w);
    }
}